import Systemdemo, {
    fill_cell, fill_cell_ex,
    get_cell_value,
    getLastColumnIndexOfSheet
} from '@/components/ts/systemdemo'
import systemdemo from '@/components/ts/systemdemo'
import {df_from_excel, Series, DataFrame} from '@/components/ts/EtPandas'
import lodash from 'lodash'
import {useCCPPStore, CorrectParaName} from '@/store'
import {CurveRegion, CurveNames} from "@/components/ts/修正曲线";

const store = useCCPPStore()


interface ParameterInstance {
    name: CorrectParaName;

    [key: string]: any;
}


export const correct_index = (correct_paras: (string | ParameterInstance)[]) => {
    /**
     * 根据修正参数列表，生成联合循环机组的功率和热耗率修正计算项的行表头
     */
    let res = []
    for (let i of correct_paras) {
        const isString = i instanceof String

        i = i as ParameterInstance
        const name = isString ? i : i.name
        if (name === '大气压力') {
            res.push(...[
                ['', '', ''],
                ['', '试验大气压力', 'kPa'],
                ['', '设计大气压力', 'kPa'],
                ...((lodash.includes(i.x, '大气压力变化量')) ? [['', '大气压力变化量', 'kPa']] : []),
                ['', '大气压力对功率修正系数', '/'],
                ['', '大气压力对热耗率修正系数', '/']
            ])
        } else if (name === '大气温度') {
            res.push(...[
                ['', '', ''],
                ['', '试验大气温度', '℃'],
                ['', '设计大气温度', '℃'],
                ...((lodash.includes(i.x, '大气温度变化量')) ? [['', '大气温度变化量', '℃']] : []),
                ['', '大气温度对功率修正系数', '/'],
                ['', '大气温度对热耗率修正系数', '/']
            ])
        } else if (name === '环境相对湿度') {
            res.push(...[
                ['', '', ''],
                ['环境湿度修正', '试验相对湿度', '%'],
                ['', '设计相对湿度', '%'],
                ...((lodash.includes(i.x, '湿度变化量')) ? [['', '相对湿度变化量', '%']] : []),
                ['', '试验环境温度', '℃'],
                ['', '查取的环境温度下边界', '℃'],
                ['', '查取的环境温度上边界', '℃'],
                ['', 'RH对功率修正系数下限', '/'],
                ['', 'RH对功率修正系数上限', '/'],
                ['', '相对湿度对功率修正系数', '/'],
                ['', '', ''],
                ['', '试验相对湿度', '%'],
                ['', '设计相对湿度', '%'],
                ...((lodash.includes(i.x, '湿度变化量')) ? [['', '相对湿度变化量', '%']] : []),
                ['', '试验环境温度', '℃'],
                ['', '查取的环境温度下边界', '℃'],
                ['', '查取的环境温度上边界', '℃'],
                ['', 'RH对热耗率修正系数下限', '/'],
                ['', 'RH对热耗率修正系数上限', '/'],
                ['', '相对湿度对热耗率修正系数', '/']
            ])
        } else if (name === '燃料气低位热值') {
            res.push(...[
                ['', '', ''],
                ['燃料热值修正', '试验燃料气低位热值', 'kJ/kg'],
                ['', '设计燃料气低位热值', 'kJ/kg'],
                ...((lodash.includes(i.x, '热值变化量')) ? [['', '燃料气低位热值变化量', 'kJ/kg']] : []),
                ['', '试验燃料的C/H比', '/'],
                ['', '查取的C/H比下边界', '/'],
                ['', '查取的C/H比下边界', '/'],
                ['', 'LHV对功率修正系数下限', '/'],
                ['', 'LHV对功率修正系数上限', '/'],
                ['', 'LHV对功率修正系数', '/'],
                ['', '', ''],
                ['', '试验燃料气低位热值', 'kJ/kg'],
                ['', '设计燃料气低位热值', 'kJ/kg'],
                ...((lodash.includes(i.x, '热值变化量')) ? [['', '燃料气低位热值变化量', 'kJ/kg']] : []),
                ['', '试验燃料的C/H比', '/'],
                ['', '查取的C/H比下边界', '/'],
                ['', '查取的C/H比下边界', '/'],
                ['', 'LHV对热耗率修正系数下限', '/'],
                ['', 'LHV对热耗率修正系数上限', '/'],
                ['', 'LHV对热耗率修正系数', '/']
            ])
        } else if (name === '背压') {
            res.push(...[
                ['', '', ''],
                ['', '试验汽轮机背压', 'kPa'],
                ['', '设计汽轮机背压', 'kPa'],
                ['', '背压对功率修正系数', '/'],
                ['', '背压对热耗率修正系数', '/']
            ])
        } else if (name === '循环水温度对功率') {
            res.push(...[
                ['', '', ''],
                ['', '循环水进水温度', '℃'],
                ['', '设计循环水进水温度', '℃'],
                ['', '循环水温度差', '℃'],
                ['', '循环水进水温度对功率修正量', 'MW']
            ])
        } else if (name === '循环水流量对功率') {
            res.push(...[
                ['', '', ''],
                ['', '循环水流量', 't/h'],
                ['', '设计循环水流量', 't/h'],
                ['', '循环水流量偏差百分比', '%'],
                ['', '循环水流量对功率修正量', 'MW']
            ])
        } else if (name === '补水率') {
            res.push(...[
                ['', '', ''],
                ['', '补水率', '%'],
                ['', '设计补水率', '%'],
                ['', '补水率对功率修正系数', '/'],
                ['', '补水率对热耗率修正系数', '/']
            ])
        } else if (name === '系统泄漏量对功率') {
            res.push(...[
                ['', '', ''],
                ['', '系统泄漏量', '%'],
                ['', '系统泄漏量对功率加法修正量', 'MW']
            ])
        } else if (name === '燃机发电机频率') {
            res.push(...[
                ['', '', ''],
                ['', '燃机发电机频率', '%'],
                ['', '设计燃机发电机频率', '%'],
                ['', '燃机频率对功率修正系数', '/'],
                ['', '燃机频率对热耗率修正系数', '/']
            ])
        } else if (name === '发电机转速') {
            res.push(...[
                ['', '', ''],
                ['', '发电机转速', 'rpm'],
                ['', '设计发电机转速', 'rpm'],
                ['', '发电机转速变化量', 'rpm'],
                ['', '环境温度', '℃'],
                ['', '环境温度修正系数下限数值', '℃'],
                ['', '环境温度修正系数上限数值', '℃'],
                ['', '发电机转速对功率修正系数下限', '/'],
                ['', '发电机转速对功率修正系数上限', '/'],
                ['', '发电机转速对热耗率修正系数下限', '/'],
                ['', '发电机转速对热耗率修正系数上限', '/'],
                ['', '发电机转速对功率修正系数', '/'],
                ['', '发电机转速对热耗率修正系数', '/']

            ])
        } else if (name === '汽机发电机频率') {
            res.push(...[
                ['', '', ''],
                ['', '汽机发电机频率', '%'],
                ['', '设计汽机发电机频率', '%'],
                ['', '汽机频率对功率修正系数', '/'],
                ['', '汽机频率对热耗率修正系数', '/']
            ])
        } else if (name === '燃机发电机功率因数') {
            res.push(...[
                ['', '', ''],
                ['功率因数修正', '燃机功率因数', '/'],
                ['', '设计功率因数', '/'],
                ['', '燃机功率', 'MW'],
                ['', '查取的燃机功率下边界', 'MW'],
                ['', '查取的燃机功率上边界', 'MW'],
                ['', '功率因数对效率变化修正量下边界', '%'],
                ['', '功率因数对效率变化修正量上边界', '%'],
                ['', '燃机功率因数对效率变化修正量', '%'],
                ['', '燃机功率因数对功率加法修正量', 'MW']

            ])
        } else if (name === '汽机发电机功率因数') {
            res.push(...[
                ['', '', ''],
                ['', '汽机功率因数', '/'],
                ['', '设计功率因数', '/'],
                ['', '汽机功率', 'MW'],
                ['', '查取的汽机功率下边界', 'MW'],
                ['', '查取的汽机功率上边界', 'MW'],
                ['', '功率因数对效率变化修正量下边界', '%'],
                ['', '功率因数对效率变化修正量上边界', '%'],
                ['', '汽机功率因数对效率变化修正量', '%'],
                ['', '汽机功率因数对功率加法修正量', 'MW']
            ])
        } else if (name === '燃机发电机氢压') {
            res.push(...[
                ['', '', ''],
                ['', '燃机发电机氢压', 'MPa'],
                ['', '设计氢压', 'MPa'],
                ['', '燃机功率', 'MW'],
                ['', '查取的燃机功率下边界', 'MW'],
                ['', '查取的燃机功率上边界', 'MW'],
                ['', '氢压对效率变化修正量下限', '%'],
                ['', '氢压对效率变化修正量上限', '%'],
                ['', '燃机氢压对效率变化修正量', '%'],
                ['', '燃机氢压对功率加法修正量', 'MW']
            ])
        }
    }


    return res
}

// 添加一个辅助函数，将行索引数组转换为Excel公式（索引基于1）
export function generateExcelProductFormulaOneBased(rows: number[], columnChar: string, op: string): string {
    /**
     * 根据行索引数组和列字符生成Excel乘积公式（索引基于1）
     * @param rows - 行索引数组（基于1）
     * @param columnChar - 列字符，如 'A', 'B' 等
     * @returns Excel乘积公式字符串，如 "=D1*D4*D5"
     */
    if (rows.length === 0) {
        return '=0'
    }

    const cellRefs = rows.map(row => `${columnChar}${row + 1}`)
    return cellRefs.join(op)
}

export function summary_correct_curve(start_row: number, sheet_name: string, sp: any) {
    window.Application.Save()

    const data = [
        ['', '功率总修正系数', '/'],
        ['', '功率总加法修正量', 'MW'],
        ['', '热耗率总修正系数', '/'],
        ['', '热耗率总加法修正量', 'kJ/kWh'],
        ['', '修正后总功率', 'MW'],
        ['', '修正后热耗率', 'kJ/kWh']
    ]
    systemdemo.set_cells(start_row + 1, 1, data, sheet_name)
    const i = start_row
    const df_cur = df_from_excel(sheet_name, 1, 1, false, false)
    // console.log(df_cur)
    const var_name_series = df_cur.iloc(':', 1)
    // console.log(var_name_series)
    let rows1 = var_name_series.str.endswith('对功率修正系数').index
    let rows2 = var_name_series.str.endswith('对热耗率修正系数').index
    let rows3 = var_name_series.str.endswith('对功率加法修正量').index
    // console.log(rows1)
    for (let j = 4; j <= getLastColumnIndexOfSheet("数据整理"); j++) {
        let y_char = systemdemo.Num2ColumnChar(j)
        let power_mul = generateExcelProductFormulaOneBased(rows1, y_char, '*')
        const formula = `{correct_factor.total_power_mul}=${power_mul}`
        // console.log('formula = ', formula)
        fill_cell(i + 1, j, 'formula', formula, null, sp)
        systemdemo.set_cell_format(i + 1, j, '0.00000', sheet_name)

        let power_add = generateExcelProductFormulaOneBased(rows3, y_char, '+')
        fill_cell(i + 2, j, 'formula', `{correct_factor.total_power_add}=${power_add}`, null, sp)
        systemdemo.set_cell_format(i + 2, j, '0.000', sheet_name)

        let hr_mul = generateExcelProductFormulaOneBased(rows2, y_char, '*')
        fill_cell(i + 3, j, 'formula', `{correct_factor.total_hr_mul}=${hr_mul}`, null, sp)
        systemdemo.set_cell_format(i + 3, j, '0.00000', sheet_name)

        let power_corrected = `{unit.net_power_corrected}=({unit.net_power}+{correct_factor.total_power_add})/{correct_factor.total_power_mul}`
        fill_cell(i + 5, j, 'formula', power_corrected, null, sp)
        systemdemo.set_cell_format(i + 5, j, '0.000', sheet_name)
    }
}


/**
 * 在数组中查找与目标值最接近的一对数值
 * @param arr - 数值数组（函数内部会自动排序）
 * @param target - 目标值
 * @returns 包含两个数值的数组，分别表示小于等于目标值的最大值和大于目标值的最小值
 */
export function getNearestPair(arr: number[], target: number): [number, number] {
    // console.log(arr, target)
    // 先对数组进行排序，确保算法正确执行
    const sortedArr = [...arr].sort((a, b) => a - b)

    let left = 0
    let right = sortedArr.length - 1
    let lowerIndex = -1
    let upperIndex = -1

    while (left <= right) {
        const mid = Math.floor((left + right) / 2)

        if (sortedArr[mid] <= target) {
            lowerIndex = mid
            left = mid + 1
        } else {
            upperIndex = mid
            right = mid - 1
        }
    }

    // 如果没找到上界值，则设为数组最后一个元素
    if (upperIndex === -1 && lowerIndex < sortedArr.length - 1) {
        upperIndex = lowerIndex
        lowerIndex = upperIndex - 1
    }

    // 如果没找到下界值，则设为下一个位置
    if (lowerIndex === -1 && upperIndex > 0) {
        lowerIndex = upperIndex
        upperIndex = lowerIndex + 1
    }

    // 返回实际的值而不是索引
    const lowerValue = sortedArr[lowerIndex]
    const upperValue = sortedArr[upperIndex]

    return [lowerValue, upperValue]
}


export function correct_CCPP(start_row: number, row_count: number, sheet_name: string, sp: any,
                             curveRegions: CurveRegion,
                             pulse: number, designLHV: number, designFlowrate: number, designFlowrateUnit: string) {
    /**
     * 将修正数据填充到指定的工作表中，从start_row开始，表中的修正项表头已经填充
     * @param start_row 起始行
     * @param row_count 需要填充的行数
     */
    // console.log(sp)
    for (let j = 4; j <= getLastColumnIndexOfSheet("数据整理"); j++) {
        for (let i = start_row; i < start_row + 2 + row_count; i++) {
            let var_name = get_cell_value(i, 2, sheet_name) // 行标题
            // console.log(`B列参数名称为：${var_name}`)
            const fuel_gas = sp['fuel_gas']['href']
            const mole_region = `${fuel_gas['CH4']}:${fuel_gas['Ar']}` // 天然气组分区域，后面多次使用，可在此统一修改
            const condition_name = get_cell_value(1, j, sheet_name)
            switch (var_name) {
                case '燃机发电功率':
                    fill_cell(i, j, 'para', 'generator_turbine.power', null, sp)
                    break
                case '汽机发电功率':
                    fill_cell(i, j, 'para', 'generator_st.power', null, sp)
                    break

                case '燃机发电机励磁功率':
                    fill_cell(i, j, 'para', 'excitation_turbine.power', null, sp)
                    break
                case '汽机发电机励磁功率':
                    fill_cell(i, j, 'para', 'excitation_st.power', null, sp)
                    break

                case '发电功率':
                case '发电机功率':
                    // console.log(`B列参数名称为：${var_name}`)
                    // console.log(sp)
                    fill_cell(i, j, 'para', 'generator.power', null, sp)
                    break
                case '发电机励磁功率':
                    fill_cell(i, j, 'para', 'excitation.power', null, sp)
                    break

                case '机组净功率':
                    const cell_last_row_1 = get_cell_value(i - 1, 2, sheet_name)
                    const cell_last_row_2 = get_cell_value(i - 2, 2, sheet_name)
                    if (cell_last_row_1 === '发电机励磁功率' && cell_last_row_2 === '发电功率') {
                        fill_cell(i, j, 'formula', '{unit.net_power}={row-2}-{row-1}', null, sp)
                    } else {
                        fill_cell(i, j, 'formula', '{unit.net_power}={row-4}+{row-3}-{row-2}-{row-1}', null, sp)
                    }
                    break
                case '天然气压力':
                case '燃料气压力':
                    fill_cell(i, j, 'para', 'fuel_gas.P', null, sp)
                    break
                case '天然气温度':
                case '燃料气温度':
                    fill_cell(i, j, 'para', 'fuel_gas.T', null, sp)
                    break
                case '天然气摩尔流量':
                    const cell_value1 = get_cell_value(i - 7, 2, sheet_name)
                    const cell_value2 = get_cell_value(i - 4, 2, sheet_name)
                    // console.log(condition_name)
                    if (cell_value1 === '流量计脉冲数') {
                        fill_cell(i - 9, j, 'para', 'fuel_gas.P', null, sp)
                        fill_cell(i - 8, j, 'para', 'fuel_gas.T', null, sp)
                        fill_cell(i - 5, j, 'formula', `{fuel_gas.Density}=yk.密度_燃气({row-4},{row-3},${mole_region})`, null, sp)
                        fill_cell(i - 3, j, 'formula', `{fuel_gas.Density_std}=yk.密度_燃气(0.101325,15,${mole_region})`, null, sp)
                        if (condition_name === '设计工况') {
                            if (designFlowrateUnit === 'kg/h') {
                                fill_cell(i - 7, j, 'formula', `{fuel_gas.Pulse}={row+1}*${pulse}`, null, sp)
                                fill_cell(i - 6, j, 'formula', `{fuel_gas.Q}={row+2}/{row+1}`, null, sp)
                                fill_cell(i - 4, j, 'formula', `{fuel_gas.F}=${designFlowrate}`, null, sp)
                                fill_cell_ex(i - 2, j, 'formula', `{fuel_gas.Q_std_design}={row-2}/{row-1}`, null, sp, true)
                            } else if (designFlowrateUnit === 'Nm3/h') {
                                fill_cell(i - 7, j, 'formula', `{fuel_gas.Pulse}={row+1}*${pulse}`, null, sp)
                                fill_cell(i - 6, j, 'formula', `{fuel_gas.Q}={row+2}/{row+1}`, null, sp)
                                fill_cell(i - 4, j, 'formula', `{fuel_gas.F}={row+1}*{row+2}`, null, sp)
                                fill_cell_ex(i - 2, j, 'formula', `{fuel_gas.Q_std_design}=${designFlowrate}`, null, sp, true)
                            } else {

                            }

                        } else {
                            fill_cell(i - 7, j, 'para', 'fuel_gas.Pulse', null, sp)
                            fill_cell(i - 6, j, 'formula', `{fuel_gas.Q}={row-1}/${pulse}`, null, sp)
                            fill_cell(i - 4, j, 'formula', `{fuel_gas.F}={row-1}*{row-2}`, null, sp)
                            fill_cell_ex(i - 2, j, 'formula', `{fuel_gas.Q_std}={row-2}/{row-1}`, null, sp, true)
                        }
                        systemdemo.set_cell_format(i - 7, j, '0', sheet_name)
                        systemdemo.set_cell_format(i - 6, j, '0.000', sheet_name)
                        systemdemo.set_cell_format(i - 5, j, '0.000', sheet_name)
                        systemdemo.set_cell_format(i - 4, j, '0.0', sheet_name)
                        systemdemo.set_cell_format(i - 3, j, '0.000', sheet_name)
                        systemdemo.set_cell_format(i - 2, j, '0.000', sheet_name)

                    } else if (cell_value2 === '标况下天然气体积流量') {
                        fill_cell(i - 4, j, 'para', 'fuel_gas.Q_std', null, sp)
                        fill_cell(i - 3, j, 'formula', `{fuel_gas.Density_std}=yk.密度_燃气(0.101325,15,${mole_region})`, null, sp)
                        fill_cell(i - 2, j, 'formula', `{fuel_gas.F}={row-1}*{row-2}`, null, sp)
                    } else {
                        fill_cell(i - 2, j, 'para', 'fuel_gas.F', null, sp)
                    }
                    fill_cell(i - 1, j, 'formula', `{fuel_gas.MolarMass}=yk.摩尔质量_燃气(${mole_region})`, null, sp)
                    fill_cell(i, j, 'formula', `{fuel_gas.F_mole}={fuel_gas.F}/{row-1}`, null, sp)
                    systemdemo.set_cell_format(i - 1, j, '0.000', sheet_name)
                    systemdemo.set_cell_format(i, j, '0.0', sheet_name)
                    break
                case '联合循环热耗量':
                    fill_cell(i - 4, j, 'formula', `{fuel_gas.H}=yk.焓_燃气({fuel_gas.T},15,${mole_region})`, null, sp)
                    if (condition_name === '设计工况') {
                        fill_cell(i - 3, j, 'formula', `{fuel_gas.LHV}=${designLHV}`, null, sp) // 直接取设计的热值
                    } else {
                        const lhv_formula = `{fuel_gas.LHV}=yk.LHV_gas(${fuel_gas['CH4']}:${fuel_gas['Ar']})`
                        fill_cell(i - 3, j, 'formula', lhv_formula, null, sp)
                    }
                    fill_cell(i - 2, j, 'formula', `{fuel_gas.显热能量流}={row-2}*{fuel_gas.F}`, null, sp)
                    fill_cell(i - 1, j, 'formula', `{fuel_gas.输入热量流}={row-2}*{fuel_gas.F}`, null, sp)
                    fill_cell(i, j, 'formula', `{fuel_gas.E}={row-2}+{row-1}`, null, sp)
                    fill_cell(i + 1, j, 'formula', `{unit.hr}={row-1}/{unit.net_power}/1000`, null, sp)
                    fill_cell(i + 2, j, 'formula', `{unit.eta}=3600/{row-1}`, null, sp)
                    fill_cell(i + 3, j, 'formula', `{unit.气耗率}={fuel_gas.Q_std}/{unit.net_power}/1000`, null, sp)
                    fill_cell(i + 4, j, 'formula', `{unit.发电煤耗}={row-3}/29.306`, null, sp)
                    break
                case '大气压力对功率修正系数':
                    // 从curveRegions中获取大气压力对功率修正系数的数据所在的区域
                    if (!curveRegions) {
                        alert(`未找到修正曲线数据，请检查`)
                        break
                    }
                    const region = curveRegions.get('大气压力_功率')
                    if (region) {
                        const startRow = region.startRow
                        const endRow = region.endRow
                        const startCol = systemdemo.Num2ColumnChar(region.startCol)
                        const endCol = systemdemo.Num2ColumnChar(region.endCol)
                        const corr_sheet = '修正曲线'
                        const x_region = `${corr_sheet}!${startCol}${startRow}:${endCol}${startRow}`
                        const y_region = `${corr_sheet}!${startCol}${endRow}:${endCol}${endRow}`
                        const t1 = store.get_corr_para('大气压力')
                        if (t1 === null || lodash.includes((t1 as any).x, '大气压力值')) { // 如果大气压力修正的x轴是大气压力值
                            const formula = `{correct_factor.P_env_power}=yk.xz({row-2},${x_region},${y_region})`
                            // console.log(formula)
                            fill_cell(i - 2, j, 'para', 'environment.P', null, sp)
                            systemdemo.set_cell_format(i - 2, j, '0.0', sheet_name)
                            fill_cell(i - 1, j, 'para', 'environment.P_design', null, sp)
                            systemdemo.set_cell_format(i - 1, j, '0.0', sheet_name)
                            fill_cell(i, j, 'formula', formula, null, sp)
                            systemdemo.set_cell_format(i, j, '0.00000', sheet_name)
                        } else if (lodash.includes((t1 as any).x, '大气压力变化量')) { // 大气压力修正的x轴是大气压力变化值
                            const formula = `{correct_factor.P_env_power}=yk.xz({row-1},${x_region},${y_region})`
                            fill_cell(i - 3, j, 'para', 'environment.P', null, sp)
                            systemdemo.set_cell_format(i - 3, j, '0.0', sheet_name)
                            fill_cell(i - 2, j, 'para', 'environment.P_design', null, sp)
                            systemdemo.set_cell_format(i - 2, j, '0.0', sheet_name)
                            fill_cell(i - 1, j, 'formula', `{correct_factor.大气压力变化量}={row-2}-{row-1}`, null, sp)

                            fill_cell(i, j, 'formula', formula, null, sp)
                            systemdemo.set_cell_format(i, j, '0.00000', sheet_name)
                        }
                    } else {
                        alert(`未找到修正曲线数据，请检查`)
                    }
                    break
                case '大气压力对热耗率修正系数':
                    if (curveRegions) {
                        const region = curveRegions.get('大气压力_热耗率')
                        if (region) {
                            const startRow = region.startRow
                            const endRow = region.endRow
                            const startCol = systemdemo.Num2ColumnChar(region.startCol)
                            const endCol = systemdemo.Num2ColumnChar(region.endCol)
                            const corr_sheet = '修正曲线'
                            const x_region = `${corr_sheet}!${startCol}${startRow}:${endCol}${startRow}`
                            const y_region = `${corr_sheet}!${startCol}${endRow}:${endCol}${endRow}`
                            const t1 = store.get_corr_para('大气压力')
                            if (t1 === null || lodash.includes((t1 as any).x, '大气压力值')) { // 如果大气压力修正的x轴是大气压力值
                                const formula = `{correct_factor.P_env_hr}=yk.xz({row-3},${x_region},${y_region})`
                                fill_cell(i, j, 'formula', formula, null, sp)
                            } else if (lodash.includes((t1 as any).x, '大气压力变化量')) {
                                const formula = `{correct_factor.P_env_hr}=yk.xz({row-2},${x_region},${y_region})`
                                fill_cell(i, j, 'formula', formula, null, sp)
                            }
                        } else {
                            alert(`未找到修正曲线数据，请检查`)
                        }
                    } else {
                        alert(`未找到修正曲线数据，请检查`)
                    }
                    break
                case '大气温度对功率修正系数':
                    if (curveRegions) {
                        const region = curveRegions.get('大气温度_功率')
                        if (region) {
                            const startRow = region.startRow
                            const endRow = region.endRow
                            const startCol = systemdemo.Num2ColumnChar(region.startCol)
                            const endCol = systemdemo.Num2ColumnChar(region.endCol)
                            const corr_sheet = region.sheet_name
                            const x_region = `${corr_sheet}!${startCol}${startRow}:${endCol}${startRow}`
                            const y_region = `${corr_sheet}!${startCol}${endRow}:${endCol}${endRow}`
                            const t1 = store.get_corr_para('大气温度')
                            if (t1 === null || lodash.includes((t1 as any).x, '大气温度值')) { // 如果大气压力修正的x轴是大气压力值
                                const formula = `{correct_factor.T_env_power}=yk.xz({row-2},${x_region},${y_region})`
                                // console.log(formula)
                                fill_cell(i - 2, j, 'para', 'environment.T', null, sp)
                                systemdemo.set_cell_format(i - 2, j, '0.0', sheet_name)
                                fill_cell(i - 1, j, 'para', 'environment.T_design', 'delete', sp)
                                systemdemo.set_cell_format(i - 1, j, '0.0', sheet_name)
                                fill_cell(i, j, 'formula', formula, 'delete', sp)
                                systemdemo.set_cell_format(i, j, '0.00000', sheet_name)
                            } else if (lodash.includes((t1 as any).x, '大气温度变化量')) {
                                const formula = `{correct_factor.T_env_power}=yk.xz({row-1},${x_region},${y_region})`
                                // console.log(formula)
                                fill_cell(i - 3, j, 'para', 'environment.T', null, sp)
                                fill_cell(i - 2, j, 'para', 'environment.T_design', 'delete', sp)
                                fill_cell(i - 1, j, 'formula', `correct_factor.大气温度变化量={row-2}-{row-1}`, 'delete', sp)
                                fill_cell(i, j, 'formula', formula, 'delete', sp)
                                systemdemo.set_cell_format(i, j, '0.00000', sheet_name)
                            }
                        } else {
                            alert(`未找到修正曲线数据，请检查`)
                        }
                    } else {
                        alert(`未找到修正曲线数据，请检查`)
                    }
                    break
                case '大气温度对热耗率修正系数':
                    if (curveRegions) {
                        const region = curveRegions.get('大气温度_热耗率')
                        if (region) {
                            const startRow = region.startRow
                            const endRow = region.endRow
                            const startCol = systemdemo.Num2ColumnChar(region.startCol)
                            const endCol = systemdemo.Num2ColumnChar(region.endCol)
                            const corr_sheet = region.sheet_name
                            const x_region = `${corr_sheet}!${startCol}${startRow}:${endCol}${startRow}`
                            const y_region = `${corr_sheet}!${startCol}${endRow}:${endCol}${endRow}`
                            const t1 = store.get_corr_para('大气温度')
                            if (t1 === null || lodash.includes((t1 as any).x, '大气温度值')) {
                                const formula = `{correct_factor.T_env_heat_rate}=yk.xz({row-3},${x_region},${y_region})`
                                fill_cell(i, j, 'formula', formula, 'delete', sp)
                            } else {
                                const formula = `{correct_factor.T_env_heat_rate}=yk.xz({row-2},${x_region},${y_region})`
                                fill_cell(i, j, 'formula', formula, 'delete', sp)
                            }
                            systemdemo.set_cell_format(i, j, '0.00000', sheet_name)
                        } else {
                            alert(`未找到修正曲线数据，请检查`)
                        }
                    } else {
                        alert(`未找到修正曲线数据，请检查`)
                    }
                    break
                case '试验相对湿度':
                    fill_cell(i, j, 'para', 'environment.RH', 'delete', sp)
                    fill_cell(i + 1, j, 'para', 'environment.RH_design', 'delete', sp)
                    const t1 = store.get_corr_para('环境相对湿度')
                    if (t1 === null || lodash.includes(t1.x, '湿度值')) {
                        fill_cell(i + 2, j, 'para', 'environment.T', 'delete', sp)
                    } else {
                        fill_cell(i + 2, j, 'formula', 'correct_factor.环境湿度变化量={row-2}-{row-1}', 'delete', sp)
                        fill_cell(i + 3, j, 'para', 'environment.T', 'delete', sp)
                    }
                    break
                case 'RH对功率修正系数':
                case '相对湿度对功率修正系数':
                    if (curveRegions) {
                        const region = curveRegions.get('RH_功率')
                        if (region) {
                            const T_row = region.startRow
                            const T_start_col = region.startCol
                            const T_end_col = region.endCol
                            const corr_sheet = region.sheet_name
                            const df_t = df_from_excel(corr_sheet, T_row, T_start_col, false, false, T_row, T_end_col)
                            const T_value = get_cell_value(i - 5, j, sheet_name)
                            const t_list = df_t.iloc(0)
                            const t = t_list.unique()
                            const [s, e] = getNearestPair(t, T_value)

                            const indices1: Series = t_list.map((value, index) => value === s ? index : -1).filter(index => index !== -1)
                            const indices2: Series = t_list.map((value, index) => value === e ? index : -1).filter(index => index !== -1)
                            // 在corr_sheet表的region中查找"环境温度_℃"为s和e对应的列的范围
                            const s_start_col = systemdemo.Num2ColumnChar(indices1.min() + 2)
                            const s_end_col = systemdemo.Num2ColumnChar(indices1.max() + 2)
                            const e_start_col = systemdemo.Num2ColumnChar(indices2.min() + 2)
                            const e_end_col = systemdemo.Num2ColumnChar(indices2.max() + 2)

                            const t1 = store.get_corr_para('环境相对湿度')
                            let formula1, formula2
                            if (t1 === null || lodash.includes(t1.x, '湿度值')) {
                                // RH对热耗率修正系数下限
                                formula1 = `{correct_factor.rh_power_t_miny}=yk.xz({row-5}, ${corr_sheet}!${s_start_col}${T_row + 1}:${s_end_col}${T_row + 1}, ${corr_sheet}!${s_start_col}${T_row + 2}:${s_end_col}${T_row + 2})`

                                // RH对热耗率修正系数上限
                                formula2 = `{correct_factor.rh_power_t_maxy}=yk.xz({row-6}, ${corr_sheet}!${e_start_col}${T_row + 1}:${e_end_col}${T_row + 1}, ${corr_sheet}!${e_start_col}${T_row + 2}:${e_end_col}${T_row + 2})`
                            } else {
                                // RH对热耗率修正系数下限
                                formula1 = `{correct_factor.rh_power_t_miny}=yk.xz({row-4}, ${corr_sheet}!${s_start_col}${T_row + 1}:${s_end_col}${T_row + 1}, ${corr_sheet}!${s_start_col}${T_row + 2}:${s_end_col}${T_row + 2})`

                                // RH对热耗率修正系数上限
                                formula2 = `{correct_factor.rh_power_t_maxy}=yk.xz({row-5}, ${corr_sheet}!${e_start_col}${T_row + 1}:${e_end_col}${T_row + 1}, ${corr_sheet}!${e_start_col}${T_row + 2}:${e_end_col}${T_row + 2})`
                            }
                            // RH对功率修正系数
                            const formula3 = `{correct_factor.rh_power}=yk.xz({row-5},{row-4}:{row-3},{row-2}:{row-1})`

                            fill_cell(i - 4, j, 'formula', `{correct_factor.rh_power_t_minx}=${s}`, 'delete', sp)
                            fill_cell(i - 3, j, 'formula', `{correct_factor.rh_power_t_maxx}=${e}`, 'delete', sp)
                            fill_cell(i - 2, j, 'formula', formula1, 'delete', sp)
                            fill_cell(i - 1, j, 'formula', formula2, 'delete', sp)
                            fill_cell(i, j, 'formula', formula3, 'delete', sp)
                            systemdemo.set_cell_format(i - 4, j, '0.0', sheet_name)
                            systemdemo.set_cell_format(i - 3, j, '0.0', sheet_name)
                            systemdemo.set_cell_format(i - 2, j, '0.00000', sheet_name)
                            systemdemo.set_cell_format(i - 1, j, '0.00000', sheet_name)
                            systemdemo.set_cell_format(i, j, '0.00000', sheet_name)
                        } else {
                            console.log(`未找到修正曲线数据，请检查`)
                        }
                    } else {
                        console.log(`未找到修正曲线数据，请检查`)
                    }
                    break
                case 'RH对热耗率修正系数':
                case '相对湿度对热耗率修正系数':
                    if (curveRegions) {
                        const region = curveRegions.get('RH_热耗率')
                        if (region) {
                            const T_row = region.startRow
                            const T_start_col = region.startCol
                            const T_end_col = region.endCol
                            const corr_sheet = region.sheet_name
                            const df_t = df_from_excel(corr_sheet, T_row, T_start_col, false, false, T_row, T_end_col)
                            const T_value = get_cell_value(i - 5, j, sheet_name)
                            const t_list = df_t.iloc(0)
                            const t = t_list.unique()
                            const [s, e] = getNearestPair(t, T_value)

                            const indices1: Series = t_list.map((value, index) => value === s ? index : -1).filter(index => index !== -1)
                            const indices2: Series = t_list.map((value, index) => value === e ? index : -1).filter(index => index !== -1)
                            // 在corr_sheet表的region中查找"环境温度_℃"为s和e对应的列的范围
                            const s_start_col = systemdemo.Num2ColumnChar(indices1.min() + 2)
                            const s_end_col = systemdemo.Num2ColumnChar(indices1.max() + 2)
                            const e_start_col = systemdemo.Num2ColumnChar(indices2.min() + 2)
                            const e_end_col = systemdemo.Num2ColumnChar(indices2.max() + 2)

                            const t1 = store.get_corr_para('环境相对湿度')
                            let formula1, formula2
                            if (t1 === null || lodash.includes(t1.x, '湿度值')) {
                                formula1 = `{correct_factor.rh_hr_t_miny}=yk.xz({row-5}, ${corr_sheet}!${s_start_col}${T_row + 1}:${s_end_col}${T_row + 1}, ${corr_sheet}!${s_start_col}${T_row + 2}:${s_end_col}${T_row + 2})`
                                formula2 = `{correct_factor.rh_hr_t_maxy}=yk.xz({row-6}, ${corr_sheet}!${e_start_col}${T_row + 1}:${e_end_col}${T_row + 1}, ${corr_sheet}!${e_start_col}${T_row + 2}:${e_end_col}${T_row + 2})`
                            } else {
                                formula1 = `{correct_factor.rh_hr_t_miny}=yk.xz({row-4}, ${corr_sheet}!${s_start_col}${T_row + 1}:${s_end_col}${T_row + 1}, ${corr_sheet}!${s_start_col}${T_row + 2}:${s_end_col}${T_row + 2})`
                                formula2 = `{correct_factor.rh_hr_t_maxy}=yk.xz({row-5}, ${corr_sheet}!${e_start_col}${T_row + 1}:${e_end_col}${T_row + 1}, ${corr_sheet}!${e_start_col}${T_row + 2}:${e_end_col}${T_row + 2})`
                            }
                            const formula3 = `{correct_factor.rh_hr}=yk.xz({row-5},{row-4}:{row-3},{row-2}:{row-1})`
                            fill_cell(i - 4, j, 'formula', `{correct_factor.rh_hr_t_minx}=${s}`, 'delete', sp)
                            fill_cell(i - 3, j, 'formula', `{correct_factor.rh_hr_t_maxx}=${e}`, 'delete', sp)
                            fill_cell(i - 2, j, 'formula', formula1, 'delete', sp)
                            fill_cell(i - 1, j, 'formula', formula2, 'delete', sp)
                            fill_cell(i, j, 'formula', formula3, 'delete', sp)
                            systemdemo.set_cell_format(i - 4, j, '0.0', sheet_name)
                            systemdemo.set_cell_format(i - 3, j, '0.0', sheet_name)
                            systemdemo.set_cell_format(i - 2, j, '0.00000', sheet_name)
                            systemdemo.set_cell_format(i - 1, j, '0.00000', sheet_name)
                            systemdemo.set_cell_format(i, j, '0.00000', sheet_name)
                        } else {
                            console.log(`未找到修正曲线数据，请检查`)
                        }
                    } else {
                        console.log(`未找到修正曲线数据，请检查`)
                    }
                    break
                case '试验燃料气低位热值':
                    // console.log(sp['fuel_gas'])
                    const formula = `{fuel_gas.碳氢比_质量}=yk.碳氢比_质量(${mole_region})`
                    const lhv_design = `{fuel_gas.LHV}=yk.LHV_gas(${fuel_gas['CH4_design']}:${fuel_gas['Ar_design']})`
                    fill_cell(i, j, 'para', 'fuel_gas.LHV', 'delete', sp)
                    systemdemo.set_cell_format(i, j, '0.0', sheet_name)
                    fill_cell(i + 1, j, 'formula', lhv_design, 'delete', sp)
                    systemdemo.set_cell_format(i + 1, j, '0.0', sheet_name)

                    const _ = store.get_corr_para('燃料气低位热值')
                    if (lodash.includes(_.x, '变化量')) {
                        fill_cell(i + 2, j, 'formula', `{correct_factor.LHV变化量}={row-2}-{row-1}`, 'delete', sp)
                        fill_cell(i + 3, j, 'formula', formula, 'delete', sp)
                        systemdemo.set_cell_format(i + 2, j, '0.0', sheet_name)
                        systemdemo.set_cell_format(i + 3, j, '0.000', sheet_name)
                    } else {
                        fill_cell(i + 2, j, 'formula', formula, 'delete', sp)
                        systemdemo.set_cell_format(i + 2, j, '0.000', sheet_name)
                    }

                    break
                case 'LHV对功率修正系数':
                case '天然气热值对功率修正系数':
                    if (curveRegions) {
                        const region = curveRegions.get('LHV_功率')
                        if (region) {
                            const CH_row = region.startRow // 碳氢比所在的行
                            const CH_start_col = region.startCol
                            const CH_end_col = region.endCol
                            const corr_sheet = region.sheet_name
                            const df_CH = df_from_excel(corr_sheet, CH_row, CH_start_col, false, false, CH_row, CH_end_col)
                            const CH_value = get_cell_value(i - 5, j, sheet_name) // 试验天然气的CH比，是需要计算的
                            const CH_list = df_CH.iloc(0)
                            const CH = CH_list.unique()
                            const [s, e] = getNearestPair(CH, CH_value)
                            // console.log(s, e)

                            const indices1: Series = CH_list.map((value, index) => value === s ? index : -1).filter(index => index !== -1)
                            const indices2: Series = CH_list.map((value, index) => value === e ? index : -1).filter(index => index !== -1)
                            // 在corr_sheet表的region中查找"环境温度_℃"为s和e对应的列的范围
                            const s_start_col = systemdemo.Num2ColumnChar(indices1.min() + 2)
                            const s_end_col = systemdemo.Num2ColumnChar(indices1.max() + 2)
                            const e_start_col = systemdemo.Num2ColumnChar(indices2.min() + 2)
                            const e_end_col = systemdemo.Num2ColumnChar(indices2.max() + 2)

                            // 查取的C/H比下边界
                            fill_cell(i - 4, j, 'formula', `{correct_factor.LHV_power_t_minx}=${s}`, 'delete', sp)
                            // 查取的C/H比上边界
                            fill_cell(i - 3, j, 'formula', `{correct_factor.LHV_power_t_maxx}=${e}`, 'delete', sp)
                            systemdemo.set_cell_format(i - 4, j, '0.00', sheet_name)
                            systemdemo.set_cell_format(i - 3, j, '0.00', sheet_name)

                            const _ = store.get_corr_para('燃料气低位热值')
                            let formula1, formula2
                            if (lodash.includes(_.x, '变化量')) {
                                // LHV对功率修正系数下限
                                formula1 = `{correct_factor.LHV_power_t_miny}=yk.xz({row-4}, ${corr_sheet}!${s_start_col}${CH_row + 1}:${s_end_col}${CH_row + 1}, ${corr_sheet}!${s_start_col}${CH_row + 2}:${s_end_col}${CH_row + 2})`
                                formula2 = `{correct_factor.LHV_power_t_maxy}=yk.xz({row-5}, ${corr_sheet}!${e_start_col}${CH_row + 1}:${e_end_col}${CH_row + 1}, ${corr_sheet}!${e_start_col}${CH_row + 2}:${e_end_col}${CH_row + 2})`
                            } else {
                                formula1 = `{correct_factor.LHV_power_t_miny}=yk.xz({row-5}, ${corr_sheet}!${s_start_col}${CH_row + 1}:${s_end_col}${CH_row + 1}, ${corr_sheet}!${s_start_col}${CH_row + 2}:${s_end_col}${CH_row + 2})`
                                formula2 = `{correct_factor.LHV_power_t_maxy}=yk.xz({row-6}, ${corr_sheet}!${e_start_col}${CH_row + 1}:${e_end_col}${CH_row + 1}, ${corr_sheet}!${e_start_col}${CH_row + 2}:${e_end_col}${CH_row + 2})`
                            }
                            fill_cell(i - 2, j, 'formula', formula1, 'delete', sp)
                            fill_cell(i - 1, j, 'formula', formula2, 'delete', sp)
                            const formula3 = `{correct_factor.LVH_power}=yk.xz({row-5},{row-4}:{row-3},{row-2}:{row-1})`
                            fill_cell(i, j, 'formula', formula3, 'delete', sp)

                            systemdemo.set_cell_format(i - 2, j, '0.00000', sheet_name)
                            systemdemo.set_cell_format(i - 1, j, '0.00000', sheet_name)
                            systemdemo.set_cell_format(i, j, '0.00000', sheet_name)
                        } else {
                            console.log(`未找到修正曲线数据，请检查`)
                        }
                    } else {
                        console.log(`未找到修正曲线数据，请检查`)
                    }
                    break
                case 'LHV对热耗率修正系数':
                case '天然气热值对热耗率修正系数':
                    if (curveRegions) {
                        const region = curveRegions.get('LHV_热耗率')
                        if (region) {
                            const CH_row = region.startRow // 碳氢比所在的行
                            const CH_start_col = region.startCol
                            const CH_end_col = region.endCol
                            const corr_sheet = region.sheet_name
                            const df_CH = df_from_excel(corr_sheet, CH_row, CH_start_col, false, false, CH_row, CH_end_col)
                            const CH_value = get_cell_value(i - 5, j, sheet_name) // 试验天然气的CH比，是需要计算的
                            const CH_list = df_CH.iloc(0)
                            const CH = CH_list.unique()
                            const [s, e] = getNearestPair(CH, CH_value)
                            // console.log(s, e)

                            const indices1: Series = CH_list.map((value, index) => value === s ? index : -1).filter(index => index !== -1)
                            const indices2: Series = CH_list.map((value, index) => value === e ? index : -1).filter(index => index !== -1)
                            // 在corr_sheet表的region中查找"环境温度_℃"为s和e对应的列的范围
                            const s_start_col = systemdemo.Num2ColumnChar(indices1.min() + 2)
                            const s_end_col = systemdemo.Num2ColumnChar(indices1.max() + 2)
                            const e_start_col = systemdemo.Num2ColumnChar(indices2.min() + 2)
                            const e_end_col = systemdemo.Num2ColumnChar(indices2.max() + 2)

                            // 查取的C/H下边界
                            fill_cell(i - 4, j, 'formula', `{correct_factor.LHV_hr_t_minx}=${s}`, 'delete', sp)
                            // 查取的C/H上边界
                            fill_cell(i - 3, j, 'formula', `{correct_factor.LHV_hr_t_maxx}=${e}`, 'delete', sp)

                            const _ = store.get_corr_para('燃料气低位热值')
                            let formula1, formula2
                            if (lodash.includes(_.x, '变化量')) {
                                formula1 = `{correct_factor.LHV_hr_t_miny}=yk.xz({row-4}, ${corr_sheet}!${s_start_col}${CH_row + 1}:${s_end_col}${CH_row + 1}, ${corr_sheet}!${s_start_col}${CH_row + 2}:${s_end_col}${CH_row + 2})`
                                formula2 = `{correct_factor.LHV_hr_t_maxy}=yk.xz({row-5}, ${corr_sheet}!${e_start_col}${CH_row + 1}:${e_end_col}${CH_row + 1}, ${corr_sheet}!${e_start_col}${CH_row + 2}:${e_end_col}${CH_row + 2})`
                            } else {
                                formula1 = `{correct_factor.LHV_hr_t_miny}=yk.xz({row-5}, ${corr_sheet}!${s_start_col}${CH_row + 1}:${s_end_col}${CH_row + 1}, ${corr_sheet}!${s_start_col}${CH_row + 2}:${s_end_col}${CH_row + 2})`
                                formula2 = `{correct_factor.LHV_hr_t_maxy}=yk.xz({row-6}, ${corr_sheet}!${e_start_col}${CH_row + 1}:${e_end_col}${CH_row + 1}, ${corr_sheet}!${e_start_col}${CH_row + 2}:${e_end_col}${CH_row + 2})`
                            }
                            const formula3 = `{correct_factor.LVH_hr}=yk.xz({row-5},{row-4}:{row-3},{row-2}:{row-1})`
                            fill_cell(i - 2, j, 'formula', formula1, 'delete', sp)
                            fill_cell(i - 1, j, 'formula', formula2, 'delete', sp)
                            fill_cell(i, j, 'formula', formula3, 'delete', sp)
                            systemdemo.set_cell_format(i - 4, j, '0.00', sheet_name)
                            systemdemo.set_cell_format(i - 3, j, '0.00', sheet_name)
                            systemdemo.set_cell_format(i - 2, j, '0.00000', sheet_name)
                            systemdemo.set_cell_format(i - 1, j, '0.00000', sheet_name)
                            systemdemo.set_cell_format(i, j, '0.00000', sheet_name)
                        } else {
                            console.log(`未找到修正曲线数据，请检查`)
                        }
                    } else {
                        console.log(`未找到修正曲线数据，请检查`)
                    }
                    break
                case '循环水进水温度对功率修正量':
                    if (curveRegions) {
                        const region = curveRegions.get('循环水温度_功率')
                        if (region) {
                            const start_row = region.startRow // 碳氢比所在的行
                            const start_col = systemdemo.Num2ColumnChar(region.startCol)
                            const end_col = systemdemo.Num2ColumnChar(region.endCol)
                            const end_row = region.endRow
                            const corr_sheet = region.sheet_name
                            let _ = store.get_corr_para('循环水温度对功率')
                            const xRegion = `${corr_sheet}!${start_col}${start_row}:${end_col}${start_row}`
                            const yRegion = `${corr_sheet}!${start_col}${end_row}:${end_col}${end_row}`
                            if (lodash.includes(_.x, '变化量')) {
                                fill_cell(i - 3, j, 'para', 'condenser_recycled_water_in.T', 'delete', sp)
                                fill_cell(i - 2, j, 'para', 'condenser_recycled_water_in.T_design', 'delete', sp)
                                fill_cell(i - 1, j, 'formula', `{correct_factor.循环水温度变化量}={row-2}-{row-1}`, 'delete', sp)
                                const formula = `{correct_factor.循环水温度_power}=yk.xz({row-1}, ${xRegion}, ${yRegion})`
                                fill_cell(i, j, 'formula', formula, 'delete', sp)
                            } else {
                                fill_cell(i - 2, j, 'para', 'condenser_recycled_water_in.T', 'delete', sp)
                                fill_cell(i - 1, j, 'para', 'condenser_recycled_water_in.T_design', 'delete', sp)
                                const formula = `{correct_factor.循环水温度_power}=yk.xz({row-2}, ${xRegion}, ${yRegion})`
                                fill_cell(i, j, 'formula', formula, 'delete', sp)
                            }
                        }
                    }
                    break
                case '循环水流量对功率修正量':
                    if (curveRegions) {
                        const region = curveRegions.get('循环水流量_功率')
                        if (region) {
                            const start_row = region.startRow // 碳氢比所在的行
                            const start_col = systemdemo.Num2ColumnChar(region.startCol)
                            const end_col = systemdemo.Num2ColumnChar(region.endCol)
                            const end_row = region.endRow
                            const corr_sheet = region.sheet_name
                            let _ = store.get_corr_para('循环水流量对功率')
                            const xRegion = `${corr_sheet}!${start_col}${start_row}:${end_col}${start_row}`
                            const yRegion = `${corr_sheet}!${start_col}${end_row}:${end_col}${end_row}`
                            if (lodash.includes(_.x, '变化量')) {
                                fill_cell(i - 3, j, 'para', 'condenser_recycled_water_in.F', 'watch', sp)
                                fill_cell(i - 2, j, 'para', 'condenser_recycled_water_in.F_design', 'watch', sp)
                                fill_cell(i - 1, j, 'formula', `{correct_factor.循环水温度变化量}={row-2}-{row-1}`, 'delete', sp)
                                const formula = `{correct_factor.循环水温度_power}=yk.xz({row-1}, ${xRegion}, ${yRegion})`
                                fill_cell(i, j, 'formula', formula, 'delete', sp)
                            } else {
                                fill_cell(i - 2, j, 'para', 'condenser_recycled_water_in.T', 'delete', sp)
                                fill_cell(i - 1, j, 'para', 'condenser_recycled_water_in.T_design', 'delete', sp)
                                const formula = `{correct_factor.循环水温度_power}=yk.xz({row-2}, ${xRegion}, ${yRegion})`
                                fill_cell(i, j, 'formula', formula, 'delete', sp)
                            }
                        }
                    }
                    break
                case '背压对功率修正系数':
                    if (curveRegions) {
                        const region = curveRegions.get('背压_功率')
                        if (region) {
                            const startRow = region.startRow
                            const endRow = region.endRow
                            const startCol = systemdemo.Num2ColumnChar(region.startCol)
                            const endCol = systemdemo.Num2ColumnChar(region.endCol)
                            const corr_sheet = '修正曲线'
                            const x_region = `${corr_sheet}!${startCol}${startRow}:${endCol}${startRow}`
                            const y_region = `${corr_sheet}!${startCol}${endRow}:${endCol}${endRow}`
                            const formula = `{correct_factor.P_cond_power}=xz({row-2},${x_region},${y_region})`
                            // console.log(formula)
                            fill_cell(i - 2, j, 'para', 'outlet_low.P', 'delete', sp)
                            systemdemo.set_cell_format(i - 2, j, '0.0', sheet_name)
                            fill_cell(i - 1, j, 'para', 'outlet_low.P_design', 'delete', sp)
                            systemdemo.set_cell_format(i - 1, j, '0.0', sheet_name)
                            fill_cell(i, j, 'formula', formula, 'delete', sp)
                            systemdemo.set_cell_format(i, j, '0.00000', sheet_name)
                        } else {
                            console.log(`未找到修正曲线数据，请检查`)
                        }
                    } else {
                        console.log(`未找到修正曲线数据，请检查`)
                    }
                    break
                case '背压对热耗率修正系数':
                    if (curveRegions) {
                        const region = curveRegions.get('背压_热耗率')
                        if (region) {
                            const startRow = region.startRow
                            const endRow = region.endRow
                            const startCol = systemdemo.Num2ColumnChar(region.startCol)
                            const endCol = systemdemo.Num2ColumnChar(region.endCol)
                            const corr_sheet = '修正曲线'
                            const x_region = `${corr_sheet}!${startCol}${startRow}:${endCol}${startRow}`
                            const y_region = `${corr_sheet}!${startCol}${endRow}:${endCol}${endRow}`
                            const formula = `{correct_factor.P_cond_heat_rate}=xz({row-2},${x_region},${y_region})`
                            // console.log(formula)
                            fill_cell(i, j, 'formula', formula, 'delete', sp)
                            systemdemo.set_cell_format(i, j, '0.00000', sheet_name)
                        } else {
                            fill_cell(i, j, 'formula', '{correct_factor.P_cond_heat_rate}=xz({row-2},)', 'delete', sp)
                        }
                    } else {
                        fill_cell(i, j, 'formula', '{correct_factor.P_cond_heat_rate}=xz({row-2},)', 'delete', sp)
                    }
                    break

                case '发电机转速':
                    if (curveRegions) {
                        let _ = store.get_corr_para('发电机转速')
                        if (lodash.includes(_.x, '变化量')) {
                            fill_cell(i, j, 'para', 'generator.rpm', 'delete', sp)
                            fill_cell(i + 1, j, 'para', 'generator.rpm_design', 'delete', sp)
                            fill_cell(i + 2, j, 'formula', `{correct_factor.发电机转速变化量}={row-2}-{row-1}`, 'delete', sp)
                        } else {
                            fill_cell(i, j, 'para', 'generator.rpm', 'delete', sp)
                            fill_cell(i + 1, j, 'para', 'generator.rpm_design', 'delete', sp)
                        }
                    }
                    break
                case '燃机频率对功率修正系数':
                    if (curveRegions) {
                        const region = curveRegions.get('燃机频率_功率')
                        if (region) {
                            const startRow = region.startRow
                            const endRow = region.endRow
                            const startCol = systemdemo.Num2ColumnChar(region.startCol)
                            const endCol = systemdemo.Num2ColumnChar(region.endCol)
                            const corr_sheet = '修正曲线'
                            const x_region = `${corr_sheet}!${startCol}${startRow}:${endCol}${startRow}`
                            const y_region = `${corr_sheet}!${startCol}${endRow}:${endCol}${endRow}`
                            const formula = `{correct_factor.freq_gt_power}=xz({row-2},${x_region},${y_region})`
                            fill_cell(i - 2, j, 'para', 'generator_turbine.freq', 'delete', sp)
                            systemdemo.set_cell_format(i - 2, j, '0.000', sheet_name)
                            fill_cell(i - 1, j, 'para', 'generator_turbine.freq_design', 'delete', sp)
                            systemdemo.set_cell_format(i - 1, j, '0.000', sheet_name)
                            fill_cell(i, j, 'formula', formula, 'delete', sp)
                            systemdemo.set_cell_format(i, j, '0.00000', sheet_name)
                        } else {
                            console.log(`未找到修正曲线数据，请检查`)
                        }
                    } else {
                        console.log(`未找到修正曲线数据，请检查`)
                    }
                    break
                case '燃机频率对热耗率修正系数':
                    if (curveRegions) {
                        const region = curveRegions.get('燃机频率_热耗率')
                        if (region) {
                            const startRow = region.startRow
                            const endRow = region.endRow
                            const startCol = systemdemo.Num2ColumnChar(region.startCol)
                            const endCol = systemdemo.Num2ColumnChar(region.endCol)
                            const corr_sheet = '修正曲线'
                            const x_region = `${corr_sheet}!${startCol}${startRow}:${endCol}${startRow}`
                            const y_region = `${corr_sheet}!${startCol}${endRow}:${endCol}${endRow}`
                            const formula = `{correct_factor.freq_gt_hr}=xz({row-2},${x_region},${y_region})`
                            fill_cell(i, j, 'formula', formula, 'delete', sp)
                            systemdemo.set_cell_format(i, j, '0.00000', sheet_name)
                        } else {
                            console.log(`未找到修正曲线数据，请检查`)
                        }
                    } else {
                        console.log(`未找到修正曲线数据，请检查`)
                    }
                    break
                case '汽机频率对功率修正系数':
                    if (curveRegions) {
                        const region = curveRegions.get('汽机频率_功率')
                        if (region) {
                            const startRow = region.startRow
                            const endRow = region.endRow
                            const startCol = systemdemo.Num2ColumnChar(region.startCol)
                            const endCol = systemdemo.Num2ColumnChar(region.endCol)
                            const corr_sheet = '修正曲线'
                            const x_region = `${corr_sheet}!${startCol}${startRow}:${endCol}${startRow}`
                            const y_region = `${corr_sheet}!${startCol}${endRow}:${endCol}${endRow}`
                            const formula = `{correct_factor.freq_st_power}=xz({row-2},${x_region},${y_region})`
                            fill_cell(i - 2, j, 'para', 'generator_st.freq', 'delete', sp)
                            systemdemo.set_cell_format(i - 2, j, '0.000', sheet_name)
                            fill_cell(i - 1, j, 'para', 'generator_st.freq_design', 'delete', sp)
                            systemdemo.set_cell_format(i - 1, j, '0.000', sheet_name)
                            fill_cell(i, j, 'formula', formula, 'delete', sp)
                            systemdemo.set_cell_format(i, j, '0.00000', sheet_name)
                        } else {
                            console.log(`未找到修正曲线数据，请检查`)
                        }
                    } else {
                        console.log(`未找到修正曲线数据，请检查`)
                    }
                    break
                case '汽机频率对热耗率修正系数':
                    if (curveRegions) {
                        const region = curveRegions.get('汽机频率_热耗率')
                        if (region) {
                            const startRow = region.startRow
                            const endRow = region.endRow
                            const startCol = systemdemo.Num2ColumnChar(region.startCol)
                            const endCol = systemdemo.Num2ColumnChar(region.endCol)
                            const corr_sheet = '修正曲线'
                            const x_region = `${corr_sheet}!${startCol}${startRow}:${endCol}${startRow}`
                            const y_region = `${corr_sheet}!${startCol}${endRow}:${endCol}${endRow}`
                            const formula = `{correct_factor.freq_st_heat_rate}=xz({row-2},${x_region},${y_region})`
                            fill_cell(i, j, 'formula', formula, 'delete', sp)
                            systemdemo.set_cell_format(i, j, '0.00000', sheet_name)
                        } else {
                            console.log(`未找到修正曲线数据，请检查`)
                        }
                    } else {
                        console.log(`未找到修正曲线数据，请检查`)
                    }
                    break
                case '补水率对功率修正系数':
                    if (curveRegions) {
                        const region = curveRegions.get('补水率_功率')
                        if (region) {
                            const startRow = region.startRow
                            const endRow = region.endRow
                            const startCol = systemdemo.Num2ColumnChar(region.startCol)
                            const endCol = systemdemo.Num2ColumnChar(region.endCol)
                            const corr_sheet = '修正曲线'
                            const x_region = `${corr_sheet}!${startCol}${startRow}:${endCol}${startRow}`
                            const y_region = `${corr_sheet}!${startCol}${endRow}:${endCol}${endRow}`
                            const formula = `{correct_factor.rate_makeup_power}=xz({row-2},${x_region},${y_region})`
                            // console.log(formula)
                            fill_cell(i, j, 'formula', formula, 'delete', sp)
                        } else {
                            fill_cell(i, j, 'formula', '{correct_factor.rate_makeup_power}=xz({row-2},)', 'delete', sp)
                        }
                    } else {
                        fill_cell(i, j, 'formula', '{correct_factor.rate_makeup_power}=xz({row-2},)', 'delete', sp)
                    }
                    break
                case '补水率对热耗率修正系数':
                    if (curveRegions) {
                        const region = curveRegions.get('补水率_热耗率')
                        if (region) {
                            const startRow = region.startRow
                            const endRow = region.endRow
                            const startCol = systemdemo.Num2ColumnChar(region.startCol)
                            const endCol = systemdemo.Num2ColumnChar(region.endCol)
                            const corr_sheet = '修正曲线'
                            const x_region = `${corr_sheet}!${startCol}${startRow}:${endCol}${startRow}`
                            const y_region = `${corr_sheet}!${startCol}${endRow}:${endCol}${endRow}`
                            const formula = `{correct_factor.rate_makeup_heat_rate}=xz({row-2},${x_region},${y_region})`
                            // console.log(formula)
                            fill_cell(i, j, 'formula', formula, 'delete', sp)
                        } else {
                            fill_cell(i, j, 'formula', '{correct_factor.rate_makeup_heat_rate}=xz({row-2},)', 'delete', sp)
                        }
                    } else {
                        fill_cell(i, j, 'formula', '{correct_factor.rate_makeup_heat_rate}=xz({row-2},)', 'delete', sp)
                    }
                    break
                case '燃机功率因数对效率变化修正量':
                    if (curveRegions) {
                        const region = curveRegions.get('燃机功率因数_效率')
                        if (region) {
                            const corr_sheet = '修正曲线'
                            fill_cell(i - 7, j, 'para', 'generator_turbine.factor', 'delete', sp)
                            systemdemo.set_cell_format(i - 7, j, '0.000', sheet_name)
                            fill_cell(i - 6, j, 'para', 'generator_turbine.factor_design', 'delete', sp)
                            systemdemo.set_cell_format(i - 6, j, '0.000', sheet_name)
                            fill_cell(i - 5, j, 'para', 'generator_turbine.power', 'delete', sp)
                            systemdemo.set_cell_format(i - 5, j, '0.000', sheet_name)

                            const power_row = region.startRow // 碳氢比所在的行
                            const df_power = df_from_excel(corr_sheet, power_row, region.startCol, false, false, power_row, region.endCol)
                            const power_value = get_cell_value(i - 5, j, sheet_name) //
                            const power_list = df_power.iloc(0)
                            const power = power_list.unique()
                            const [s, e] = getNearestPair(power, power_value)
                            // console.log(s, e)
                            fill_cell(i - 4, j, 'formula', `{correct_factor.pf_gt_effi_power_minx}=${s}`, 'delete', sp)
                            systemdemo.set_cell_format(i - 4, j, '0.000', sheet_name)
                            fill_cell(i - 3, j, 'formula', `{correct_factor.pf_gt_effi_power_maxx}=${e}`, 'delete', sp)
                            systemdemo.set_cell_format(i - 3, j, '0.000', sheet_name)

                            const indices1: Series = power_list.map((value, index) => value === s ? index : -1).filter(index => index !== -1)
                            const indices2: Series = power_list.map((value, index) => value === e ? index : -1).filter(index => index !== -1)
                            // 在corr_sheet表的region中查找"环境温度_℃"为s和e对应的列的范围
                            const s_start_col = systemdemo.Num2ColumnChar(indices1.min() + 2)
                            const s_end_col = systemdemo.Num2ColumnChar(indices1.max() + 2)
                            const e_start_col = systemdemo.Num2ColumnChar(indices2.min() + 2)
                            const e_end_col = systemdemo.Num2ColumnChar(indices2.max() + 2)
                            const formula1 = `{correct_factor.pf_gt_effi_power_miny}=yk.xz({row-5}, ${corr_sheet}!${s_start_col}${power_row + 1}:${s_end_col}${power_row + 1}, ${corr_sheet}!${s_start_col}${power_row + 2}:${s_end_col}${power_row + 2})`
                            const formula2 = `{correct_factor.pf_gt_effi_power_maxy}=yk.xz({row-6}, ${corr_sheet}!${e_start_col}${power_row + 1}:${e_end_col}${power_row + 1}, ${corr_sheet}!${e_start_col}${power_row + 2}:${e_end_col}${power_row + 2})`
                            const formula3 = `{correct_factor.pf_gt_effi}=yk.xz({row-5},{row-4}:{row-3},{row-2}:{row-1})`
                            fill_cell(i - 2, j, 'formula', formula1, 'delete', sp)
                            fill_cell(i - 1, j, 'formula', formula2, 'delete', sp)

                            fill_cell(i, j, 'formula', formula3, 'delete', sp)
                            systemdemo.set_cell_format(i, j, '0.000', sheet_name)
                            fill_cell(i + 1, j, 'formula', `{correct_factor.pf_gt_effi_add}={row-6}*(1/(1+{row-1}/100)-1)`, 'delete', sp)
                            systemdemo.set_cell_format(i + 1, j, '0.000', sheet_name)

                            // 判断是否需要给修正量乘以-1
                            const pf1 = get_cell_value(i - 7, j, sheet_name)
                            const pf2 = get_cell_value(i - 6, j, sheet_name)
                            const pf_sign = get_cell_value(i + 1, j, sheet_name)
                            if (pf1 > pf2 && pf_sign > 0) { // 确保修正方向符合 效率随功率因数单调递增的关系
                                fill_cell(i + 1, j, 'formula', `{correct_factor.pf_gt_effi_add}={row-6}*(1-1/(1+{row-1}/100))`, 'delete', sp)
                            }
                        } else {
                            console.log(`未找到修正曲线数据，请检查`)
                        }
                    } else {
                        console.log(`未找到修正曲线数据，请检查`)
                    }
                    break
                case '汽机功率因数对效率变化修正量':
                    if (curveRegions) {
                        const region = curveRegions.get('汽机功率因数_效率')
                        if (region) {
                            const corr_sheet = '修正曲线'
                            fill_cell(i - 7, j, 'para', 'generator_st.factor', 'delete', sp)
                            systemdemo.set_cell_format(i - 7, j, '0.000', sheet_name)
                            fill_cell(i - 6, j, 'para', 'generator_st.factor_design', 'delete', sp)
                            systemdemo.set_cell_format(i - 6, j, '0.000', sheet_name)
                            fill_cell(i - 5, j, 'para', 'generator_st.power', 'delete', sp)
                            systemdemo.set_cell_format(i - 5, j, '0.000', sheet_name)

                            const power_row = region.startRow // 碳氢比所在的行
                            const df_power = df_from_excel(corr_sheet, power_row, region.startCol, false, false, power_row, region.endCol)
                            const power_value = get_cell_value(i - 5, j, sheet_name) //
                            const power_list = df_power.iloc(0)
                            const power = power_list.unique()
                            const [s, e] = getNearestPair(power, power_value)
                            // console.log(s, e)
                            fill_cell(i - 4, j, 'formula', `{correct_factor.pf_st_effi_power_minx}=${s}`, 'delete', sp)
                            systemdemo.set_cell_format(i - 4, j, '0.000', sheet_name)
                            fill_cell(i - 3, j, 'formula', `{correct_factor.pf_st_effi_power_maxx}=${e}`, 'delete', sp)
                            systemdemo.set_cell_format(i - 3, j, '0.000', sheet_name)

                            const indices1: Series = power_list.map((value, index) => value === s ? index : -1).filter(index => index !== -1)
                            const indices2: Series = power_list.map((value, index) => value === e ? index : -1).filter(index => index !== -1)
                            // 在corr_sheet表的region中查找"环境温度_℃"为s和e对应的列的范围
                            const s_start_col = systemdemo.Num2ColumnChar(indices1.min() + 2)
                            const s_end_col = systemdemo.Num2ColumnChar(indices1.max() + 2)
                            const e_start_col = systemdemo.Num2ColumnChar(indices2.min() + 2)
                            const e_end_col = systemdemo.Num2ColumnChar(indices2.max() + 2)
                            const formula1 = `{correct_factor.pf_st_effi_power_miny}=yk.xz({row-5}, ${corr_sheet}!${s_start_col}${power_row + 1}:${s_end_col}${power_row + 1}, ${corr_sheet}!${s_start_col}${power_row + 2}:${s_end_col}${power_row + 2})`
                            const formula2 = `{correct_factor.pf_st_effi_power_maxy}=yk.xz({row-6}, ${corr_sheet}!${e_start_col}${power_row + 1}:${e_end_col}${power_row + 1}, ${corr_sheet}!${e_start_col}${power_row + 2}:${e_end_col}${power_row + 2})`
                            const formula3 = `{correct_factor.pf_st_effi}=yk.xz({row-5},{row-4}:{row-3},{row-2}:{row-1})`
                            fill_cell(i - 2, j, 'formula', formula1, 'delete', sp)
                            fill_cell(i - 1, j, 'formula', formula2, 'delete', sp)

                            fill_cell(i, j, 'formula', formula3, 'delete', sp)
                            systemdemo.set_cell_format(i, j, '0.000', sheet_name)
                            fill_cell(i + 1, j, 'formula', `{correct_factor.pf_st_effi_add}={row-6}*(1/(1+{row-1}/100)-1)`, 'delete', sp)
                            systemdemo.set_cell_format(i + 1, j, '0.000', sheet_name)

                            // 判断是否需要给修正量乘以-1
                            const pf1 = get_cell_value(i - 7, j, sheet_name)
                            const pf2 = get_cell_value(i - 6, j, sheet_name)
                            const pf_sign = get_cell_value(i + 1, j, sheet_name)
                            if (pf1 > pf2 && pf_sign > 0) { // 确保修正方向符合 效率随功率因数单调递增的关系
                                fill_cell(i + 1, j, 'formula', `{correct_factor.pf_st_effi_add}={row-6}*(1-1/(1+{row-1}/100))`, 'delete', sp)
                            }
                        } else {
                            console.log(`未找到修正曲线数据，请检查`)
                        }
                    } else {
                        console.log(`未找到修正曲线数据，请检查`)
                    }
                    break
                case '燃机氢压对效率变化修正量':
                    if (curveRegions) {
                        const region = curveRegions.get('燃机氢压_效率')
                        if (region) {
                            const corr_sheet = '修正曲线'
                            fill_cell(i - 7, j, 'para', 'generator_turbine.氢压', 'delete', sp)
                            systemdemo.set_cell_format(i - 7, j, '0.000', sheet_name)
                            fill_cell(i - 6, j, 'para', 'generator_turbine.氢压_design', 'delete', sp)
                            systemdemo.set_cell_format(i - 6, j, '0.000', sheet_name)
                            fill_cell(i - 5, j, 'para', 'generator_turbine.power', 'delete', sp)
                            systemdemo.set_cell_format(i - 5, j, '0.000', sheet_name)

                            const power_row = region.startRow // 碳氢比所在的行
                            const df_power = df_from_excel(corr_sheet, power_row, region.startCol, false, false, power_row, region.endCol)
                            const power_value = get_cell_value(i - 5, j, sheet_name) //
                            const power_list = df_power.iloc(0)
                            const power = power_list.unique()
                            const [s, e] = getNearestPair(power, power_value)
                            // console.log(s, e)
                            fill_cell(i - 4, j, 'formula', `{correct_factor.氢压_gt_effi_power_minx}=${s}`, 'delete', sp)
                            systemdemo.set_cell_format(i - 4, j, '0.000', sheet_name)
                            fill_cell(i - 3, j, 'formula', `{correct_factor.氢压_gt_effi_power_maxx}=${e}`, 'delete', sp)
                            systemdemo.set_cell_format(i - 3, j, '0.000', sheet_name)

                            const indices1: Series = power_list.map((value, index) => value === s ? index : -1).filter(index => index !== -1)
                            const indices2: Series = power_list.map((value, index) => value === e ? index : -1).filter(index => index !== -1)
                            // 在corr_sheet表的region中查找"环境温度_℃"为s和e对应的列的范围
                            const s_start_col = systemdemo.Num2ColumnChar(indices1.min() + 2)
                            const s_end_col = systemdemo.Num2ColumnChar(indices1.max() + 2)
                            const e_start_col = systemdemo.Num2ColumnChar(indices2.min() + 2)
                            const e_end_col = systemdemo.Num2ColumnChar(indices2.max() + 2)
                            const formula1 = `{correct_factor.氢压_gt_effi_power_miny}=yk.xz({row-5}, ${corr_sheet}!${s_start_col}${power_row + 1}:${s_end_col}${power_row + 1}, ${corr_sheet}!${s_start_col}${power_row + 2}:${s_end_col}${power_row + 2})`
                            const formula2 = `{correct_factor.氢压_gt_effi_power_maxy}=yk.xz({row-6}, ${corr_sheet}!${e_start_col}${power_row + 1}:${e_end_col}${power_row + 1}, ${corr_sheet}!${e_start_col}${power_row + 2}:${e_end_col}${power_row + 2})`
                            const formula3 = `{correct_factor.氢压_gt_effi}=yk.xz({row-5},{row-4}:{row-3},{row-2}:{row-1})`
                            fill_cell(i - 2, j, 'formula', formula1, 'delete', sp)
                            systemdemo.set_cell_format(i - 2, j, '0.000', sheet_name)
                            fill_cell(i - 1, j, 'formula', formula2, 'delete', sp)
                            systemdemo.set_cell_format(i - 1, j, '0.000', sheet_name)

                            fill_cell(i, j, 'formula', formula3, 'delete', sp)
                            systemdemo.set_cell_format(i, j, '0.000', sheet_name)
                            fill_cell(i + 1, j, 'formula', `{correct_factor.氢压_gt_effi_add}={row-6}*(1/(1+{row-1}/100)-1)`, 'delete', sp)
                            systemdemo.set_cell_format(i + 1, j, '0.000', sheet_name)
                        } else {
                            console.log(`未找到修正曲线数据，请检查`)
                        }
                    } else {
                        console.log(`未找到修正曲线数据，请检查`)
                    }
                    break
                default:
                    break
            }
        }
    }
}

export function correct_CCPP2(start_row: number, row_count: number, sheet_name: string, sp: any, curveRegions: any = null,
                              pulse: number, designLHV: number, designFlowrate: number, designFlowrateUnit: string) {
    /**
     * 应为修正项中某些参数依赖于当前表已经计算的参数，所以等当前修正项执行后，再执行这些特殊参数的填充
     * @param start_row 起始行
     * @param row_count 需要填充的行数
     */
    // console.log(sp)
    for (let j = 4; j <= getLastColumnIndexOfSheet("数据整理"); j++) {
        for (let i = start_row; i < start_row + 2 + row_count; i++) {
            let var_name = get_cell_value(i, 2, sheet_name) // 行标题
            const fuel_gas = sp['fuel_gas']['href']
            const mole_region = `${fuel_gas['CH4']}:${fuel_gas['Ar']}` // 天然气组分区域，后面多次使用，可在此统一修改
            const condition_name = get_cell_value(1, j, sheet_name)
            switch (var_name) {
                case '联合循环热耗量':
                    fill_cell(i + 3, j, 'formula', `{unit.气耗率}={fuel_gas.Q_std}/{unit.net_power}/1000`, null, sp)
                    break
                default:
                    break
            }
        }
    }
}

export default {
    correct_index,
    correct_CCPP,
    correct_CCPP2,
    summary_correct_curve
}